package com.study;

import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    @GetMapping("")
    public Object list() {
        List<User> list = userService.list();
        return list;
    }

    @RequestMapping(value = "/save", method = {RequestMethod.POST, RequestMethod.GET})
    public Object save(User user) {
        System.out.println("user = " + user);
        userService.save(user);
        return user.getId();
    }

}
